/**
  ******************************************************************************
  * @file    Libraries/Device/TS32Fx/TS32Fx_LL_Driver/src/ts32fx_ll_lvd.c
  * @author  TOPSYS Application Team
  * @version V1.0.0
  * @date    02-11-2018
  * @brief   This file contains all the LVD LL firmware functions.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2018 TOPSYS</center></h2>
  *
  *
  *
  ******************************************************************************
  */ 

/* Includes ------------------------------------------------------------------*/
#include "include.h"

/** @addtogroup TS32Fx_StdPeriph_Driver TS32Fx Driver
  * @{
  */
  
/** @defgroup lvd_interface_gr LVD Driver
  * @ingroup  TS32Fx_StdPeriph_Driver
  * @{
  */

/** @addtogroup LVD_LL_Driver LVD LL Driver
  * @ingroup  lvd_interface_gr
  * @{
  */
  
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

  
/** @defgroup LVD_LL_Interrupt LVD LL Interrupt Handle function
  * @ingroup  LVD_LL_Driver
  * @brief   LVD LL Interrupt Handle function
  * @{
  */



/**
  * @}
  */

/** @defgroup LVD_LL_Inti_Cfg LVD LL Initialization And Configuration
  * @ingroup  LVD_LL_Driver
  * @brief    LVD LL Initialization And Configuration
  * @{
  */

/**
  * @brief  lvd_init
  * @param  p_lvd : pointer to the hardware LVD_TypeDef
  * @param  p_init: pointer to the init stuct TYPE_LL_LVD_INIT
  * @retval None
  */
void ll_lvd_init(LVD_TypeDef *p_lvd, TYPE_LL_LVD_INIT *p_init)
{
    p_lvd->LVD_CON = p_init->lvd_con_bit_map;
}

/**
  * @brief  lvd_deinit
  * @param  p_lvd : pointer to the hardware LVD_TypeDef
  * @retval None
  */
void ll_lvd_deinit(LVD_TypeDef *p_lvd)
{

}


/**
  * @}
  */

/** @defgroup LVD_LL_Data_Transfers LVD LL Data transfers functions
  * @ingroup  LVD_LL_Driver
  * @brief    LVD LL Data transfers functions 
  * @{
  */



/**
  * @brief  lvd con register set
  * @param  p_lvd : pointer to the hardware LVD_TypeDef
  * @param  con_bit_map : lvd con register bit map
  * @retval None
  */
void ll_lvd_con_set(LVD_TypeDef *p_lvd, u32 con_bit_map)
{
    p_lvd->LVD_CON = con_bit_map;
}

/**
  * @brief  lvd con register get
  * @param  p_lvd : pointer to the hardware LVD_TypeDef
  * @retval lvd con register value
  */
u32 ll_lvd_con_get(LVD_TypeDef *p_lvd)
{
    return (p_lvd->LVD_CON);
}

/**
  * @brief  use for get vdd low voltage detector enable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VDD_LVD_EN | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  use for get vdd low voltage detector disable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VDD_LVD_EN)) | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  use for get vcc low voltage detector enable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_enable(LVD_TypeDef *p_lvd)
{
    (p_lvd)->LVD_CON |= LL_LVD_CON_VCC_LVD_EN | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  use for get vcc low voltage detector disable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VCC_LVD_EN)) | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  use for get vdd low voltage detector debounce enable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_debounce_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VDD_DEBOUNCE_EN | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  use for get vdd low voltage detector debounce disable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_debounce_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VDD_DEBOUNCE_EN)) | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  use for get vcc low voltage detector debounce enable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_debounce_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VCC_DEBOUNCE_EN | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  use for get vcc low voltage detector debounce disable
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_debounce_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VCC_DEBOUNCE_EN)) | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  enable lvd interrupt or reset output when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_out_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_OUT_EN | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  disable lvd interrupt or reset output when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_out_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_OUT_EN)) | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  enable VDD low voltage detector reset when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_reset_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VDD_RST_EN | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  disable VDD low voltage detector reset when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vdd_reset_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VDD_RST_EN)) | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  enable VCC low voltage detector reset when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_reset_enable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON |= LL_LVD_CON_VCC_RST_EN | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  disable VCC low voltage detector reset when threshold is triggered
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval none
  */
void ll_lvd_vcc_reset_disable(LVD_TypeDef *p_lvd)
{
    p_lvd->LVD_CON = (p_lvd->LVD_CON & (~LL_LVD_CON_VCC_RST_EN)) | LL_LVD_CON_VCC_AND_VDD_PENDING_MASK;
}

/**
  * @brief  get vdd lvd set value
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval TYPE_ENUM_LL_LVD_VDD_LVD_SET
  */
TYPE_ENUM_LL_LVD_VDD_LVD_SET ll_lvd_vdd_lvd_get(LVD_TypeDef *p_lvd)
{
    return (TYPE_ENUM_LL_LVD_VDD_LVD_SET)(((p_lvd)->LVD_CON >> 6) & 0x03);
}

/**
  * @brief  get vcc lvd set value
  * @param  p_lvd: pointer to the hardware LVD_TypeDef *p_lvd
  * @retval TYPE_ENUM_LL_LVD_VCC_LVD_SET
  */
TYPE_ENUM_LL_LVD_VCC_LVD_SET ll_lvd_vcc_lvd_get(LVD_TypeDef *p_lvd)
{
    return (TYPE_ENUM_LL_LVD_VCC_LVD_SET)(((p_lvd)->LVD_CON >> 1) & 0x0F);
}

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

/*************************** (C) COPYRIGHT 2018 TOPSYS ***** END OF FILE *****/
